<template>
	<view class="myself">
		<get-userinfo @userClick="showContent"  v-if="isCause"> </get-userinfo>
			<view class="logoin" v-else>
				<view class="name">
						<view class="avater" v-if="islogin">
								<image :src="userData.avatarUrl" mode="aspectFill"></image>
								<view class="number">
									<text>{{userData.nickName}}</text>
									<view>
										13281013539
									</view>
								</view>
						</view>
						<view class="notlogin" v-else>
							<view class="avater"@click="login">
									<image src="../../static/denglu.png" mode="aspectFill"></image>
									<view class="number">
										<text>点击登录</text>
										<view>
											暂无更多信息
										</view>
									</view>
							</view>
						</view>
						<view class="gender">
							<view class="nan" v-if="userData.gender === 1">
									<image src="../../static/nan.png" mode="aspectFill"></image>
							</view>
							<view class="nv" v-else-if="userData.gender === 2">
									<image src="../../static/nv.png" mode="aspectFill"></image>
							</view>
							<view class="unknow" v-else>
									<image src="../../static/xingbie.png" mode="aspectFill"></image>
							</view>
						</view>
				</view>
				<view class="local" v-if="islogin">
					地址：
					<text class="city">
						{{userData.city}}
					</text>
					/
					<text class="province">
						{{userData.province}}
					</text>
					/
					<text class="country">
						{{userData.country}}
					</text>
				</view>
				<view class="more">
						暂无更多信息
				</view>
			</view>	
	</view>
</template>

<script>
	import 	getUserinfo  from '../getUserinfo'
	export default {
		components:{
			getUserinfo
		},
		data() {
			return {
				userData:{},
				// 判断是否登录
				islogin:true,
				// 隐藏授权页面
				isCause:false
			};
		},
		onLoad() {
			
		},
		mounted() {
			let _this = this
			uni.getStorage({
				key:"userinfo",
				success(e) {
					_this.userData = e.data
					_this.islogin = true
				},
				fail(e) {
					console.log(e)
				}
			})
			if(_this.userData.data === undefined){
				this.islogin = false
			}
		},
		methods:{
			login(){
				this.isCause = true
			},
			showContent(e){
				this.isCause = e
				let _this = this
				uni.getStorage({
					key:"userinfo",
					success(e) {
						_this.userData = e.data
						_this.islogin = true
					},
					fail(e) {
						console.log(e)
					}
				})
				if(_this.userData.data === undefined){
					this.islogin = false
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.myself{
		.name{
			height: 200rpx;
			background-color: aqua;
			line-height: 95rpx;
			padding-top: 25rpx;
			.avater{
				display: flex;
				width: 440rpx;
				height: 150rpx;
				justify-content: space-around;
				margin-left: 40rpx;
				image{
					width: 150rpx;
					height: 150rpx;
					border-radius: 50%;
				}
				.number{
					font-size: 38rpx;
					view{
						margin-top: -20rpx;
					}
				}	
			}
			.gender{
				position: relative;
				view{
					position: absolute;
					top: -120rpx;
					right: 75rpx;
					width: 60rpx;
					height: 60rpx;
					image{
						height: 100%;
						width: 100%;
					}
				}
			}
		}
		.local{
			height: 90rpx;
			line-height: 90rpx;
			border-bottom: 2rpx solid #ccc;
			padding-left: 55rpx;
			font-size: 46rpx;
			margin: 0 30rpx;
			txet{
				margin: 15rpx;
			}
			.city{
				color:orange;
				font-size: 46rpx;
				margin-left: 40rpx;
			}
			.province{
				color:aqua;
				font-size: 42rpx;
			}
			.country{
				color:green;
				font-size: 38rpx;
			}
		}
		
	}
		.more{
			width:1005;
			height: 700rpx;
			color: #000;
			font-weight: 600;
			font-size: 70rpx;
			line-height: 700rpx;
			text-align: center;
			}

</style>
